<%-- 
    Document   : editThread
    Created on : 05.11.2011, 15:43:34
    Author     : Дима
--%>

<%@page import="org.jdom.Element"%>
<%@page import="ru.ssau.utils.XMLHelper"%>
<%@page import="ru.ssau.server.Constants"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page errorPage="error.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>   <%
        String threadXML = (String) session.getAttribute(Constants.THREAD);
        ru.ssau.entities.Thread thread = null;
        String caption = "";
        if(threadXML != null) {
            Element threadElement = XMLHelper.parseString(threadXML);
            thread = new ru.ssau.entities.Thread();
            thread.loadFromXMLElement(threadElement);
            caption = thread.getCaption();
            session.setAttribute(Constants.ID, thread.getId());
        } %>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Add/edit thread</title>

        <style type="text/css">
            h4 {
                margin-top: 6px;
                margin-bottom: 3px;
            }
        </style>
    </head>
    <body>
        <h4>Enter data:</h4>
        <form name="threadSetForm" action="request" method="post">
            Caption:
            <input type="text" name="<%=Constants.CAPTION%>" value="<%=caption%>" size="10"/>
            <br>   <%
              if(threadXML == null) { %>
                <button name="<%=Constants.ACTION%>" value="<%=Constants.DO_ADD_THREAD%>" style="margin-top: 10px;">Add thread</button>   <%
              } else { %>
                <button name="<%=Constants.ACTION%>" value="<%=Constants.DO_EDIT_THREAD%>" style="margin-top: 10px;">Edit thread</button>   <%
              } %>
        </form>
    </body>
</html>
